﻿<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>注册</title>
<link rel="stylesheet" href="./css/register.css" />
<script src="jquery-3.4.1.min.js"></script>
<script>
var dos=false;
function oper1(){
	$.ajax({
		type:"post",
		url:"https://localhost:44316/api/Logins/",//打开后台
		data:$("input[name='title']").val(),//上传的数据
		success:function(data){
			var Tdata=data.split(",");
			if($("input[name='title']").val()==""){
				$("tr:eq(0) .tip").css("color","red");
				$("tr:eq(0) .tip").text("用户名不能为空");
			}
			else
				for(var i=0;i<Tdata.length;i++)
					if($("input[name='title']").val()==Tdata[i]){
						$("tr:eq(0) .tip").css("color","red");
						$("tr:eq(0) .tip").text("该用户已存在");
						dos=flase;
						break;
					}
					else{
						$("tr:eq(0) .tip").css("color","green");
						$("tr:eq(0) .tip").text("用户名可用");
						dos=true;
						break;
					}
		}
	})
}
function oper2(){
	var $title_data=$("input[name='passwd']").val();
	if($title_data.length>=6&&$title_data.length<=18){
		$("tr:eq(1) .tip").css("color","green");
		$("tr:eq(1) .tip").text("填写正确");
						dos=true;
	}
	else{
		$("tr:eq(1) .tip").css("color","red");
		$("tr:eq(1) .tip").text("填写错误");
						dos=flase;
	}
}
function oper3(){
	var $title_data=$("input[name='repasswd']").val();
	if($title_data==$("input[name='passwd']").val()){
		$("tr:eq(2) .tip").css("color","green");
		$("tr:eq(2) .tip").text("填写正确");
						dos=true;
	}
	else{
		$("tr:eq(2) .tip").css("color","red");
		$("tr:eq(2) .tip").text("填写错误");
						dos=flase;
	}
}
function success(){
	if(dos==true){
		window.location.href='../PolyNote/PolyNote/writer.html';	
	}
	else{
		alert("请按要求填写信息");
	}
}
</script>
</head>
<body>
<div class="goods">
<div class="title">注册信息</div>
<table class="table">
	<tr>
		<th class="th">用户名：</th>
		<td class="td">
			<input onblur="oper1()" type="text" name="title" />
			<span class="tip"></span>
			<p class="rule">用户名长度在3~10个字符之间。</p>
		</td>
	</tr>
	<tr>
		<th class="th">密码：</th>
			<td class="td">
		<input onblur="oper2()" type="password" name="passwd"><span class="tip"></span>
		<p class="rule">密码在6~18个字符以内。</p>
	</td>
	</tr>
	<tr>
		<th class="th">确认密码：</th>
			<td class="td">
		<input onblur="oper3()" type="password" name="repasswd"><span class="tip"></span>
		<p class="rule">与上面密码一致。</p>
	</td>
	</tr>
</table>
<div class="act"><a class="btn" onclick="success()">提交</a></div>
</div>
</body>
</html>